<template>
	<view class="mainbgc">
		<header-top :messageInfo="{typeFlag:true,message:titletext,liner:false}">
			<view class="rightmsg" slot="rightmsg">
				<view class="rightmsg_content">
					<view class="time" @click="history"></view>
				</view>
			</view>
		</header-top>
		<view class="strongtext  mainpadding">
			<text class="titletext textliner">签到状态</text>
		</view>
		<view class="mainpadding ffffff flexbetween">
			<view class="left flexleft">
				<image class="selectdui" src="../../../static/image/system/selectdui1.png" mode=""></image>
				<view class="righttext">
					<view class="signed">已签到</view>
					<view class="time-text">{{dataAll.signintime | formatDate('-')}}</view>
				</view>
			</view>
			<image class="rtimg" :src="dataAll.shop_avatar" mode=""></image>
		</view>
		<view class="strongtext  mainpadding">
			<text class="titletext textliner">陈列拍照</text>
		</view>
		<view class="mainpadding ffffff flexleft">
			<view class="bottombox" v-for="item in dataAll.display_images" :key="item">
				<image class="images" :src="item" mode=""></image>
			</view>
		</view>
		<view class="strongtext  mainpadding">
			<text class="titletext textliner">备注内容</text>
		</view>
		<view class="mainpadding ffffff ">
			<text class="textcontent">{{dataAll.note}}</text>
		</view>
		<view class="strongtext  mainpadding">
			<text class="titletext textliner">拜访成果</text>
		</view>
		<view class="paddingbom">
			<view class="nostrongtext ffffff mainpadding" v-for="item in dataAll.info" :key="item.type">
				<view class="flexbetween" v-show="item.type==11" @click="djhzclick(0)">
					<view>销售单{{item.number}}单，金额￥{{item.all_money}}</view>
					<view class="righticon2"></view>
				</view>
				<view class="flexbetween" v-show="item.type==12"  @click="djhzclick(1)">
					<view>退货单{{item.number}}单，金额￥{{item.all_money}}</view>
					<view class="righticon2"></view>
				</view>
				<view class="flexbetween" v-show="item.type==21"  @click="djhzclick(5)">
					<view>收款单{{item.number}}单，金额￥{{item.all_money}}</view>
					<view class="righticon2"></view>
				</view>
				<view class="flexbetween" v-show="item.type==30"  @click="djhzclick(2)">
					<view>订货单{{item.number}}单，金额￥{{item.all_money}}</view>
					<view class="righticon2"></view>
				</view>
				<view class="flexbetween" v-show="item.type==31"  @click="djhzclick(8)">
					<view>预收款单{{item.number}}单，金额￥{{item.all_money}}</view>
					<view class="righticon2"></view>
				</view>
				<view class="flexbetween" v-show="item.type==32"  @click="djhzclick(7)">
					<view>费用合同{{item.number}}单，金额￥{{item.all_money}}</view>
					<view class="righticon2"></view>
				</view>
				<view class="flexbetween" v-show="item.type==33"  @click="djhzclick(6)">
					<view>费用支出{{item.number}}单，金额￥{{item.all_money}}</view>
					<view class="righticon2"></view>
				</view>
			</view>
		</view>
		
		
		<view class="mainpadding ffffff flexbetween bottomboxs">
			<view class="left flexleft">
				<image class="selectdui" src="../../../static/image/system/selectdui1.png" mode=""></image>
				<view class="righttext">
					<view class="signed">已签退</view>
					<view class="time-text">{{dataAll.signouttime | formatDate('-')}}</view>
				</view>
			</view>
			<view class="signed">签退人：{{dataAll.staff_name}}</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				titletext:"",
				visit_id:"",
				dataAll:{
					
				}
			}
		},
		onLoad(options) {
			this.visit_id = options.id
			this.init()
		},
		filters: {
			// 时间戳处理
			formatDate: function(value, spe = '/') {
				value = value * 1000
				let data = new Date(value);
				let year = data.getFullYear();
				let month = data.getMonth() + 1;
				let day = data.getDate();
				let h = data.getHours();
				let mm = data.getMinutes();
				let s = data.getSeconds();
				month = month >= 10 ? month : "0" + month;
				day = day >= 10 ? day : "0" + day;
				h = h >= 10 ? h : "0" + h;
				mm = mm >= 10 ? mm : "0" + mm;
				s = s >= 10 ? s : "0" + s;
				return `${year}${spe}${month}${spe}${day} ${h}:${mm}:${s}`;
			}
		},
		methods: {
			init(){
				httpRequest.request('appapi/manage/visit/visit_customer_detail', 'POST', {
					id: this.visit_id
				}).then(res => {
					res.data.display_images = res.data.display_images.split(',')
					this.dataAll = res.data
					this.titletext = res.data.customer_name
				})
			},
			// 查看单据
			djhzclick(value) {
				let data = {
					current: value,
					starttime: this.date(this.dataAll.signintime * 1000),
					endtime: this.date(this.dataAll.signouttime * 1000),
					customers_id:this.dataAll.customers_id
				}
				console.log(data,"传递参数")
				
				uni.navigateTo({
					url: '/pages/workbench/xiaoshou/danjuhz?msg=' + encodeURIComponent(JSON.stringify(data))
				})
			},
			date(timer) {
				var date = new Date(timer); //当前时间
				var year = date.getFullYear() //返回指定日期的年份
				var month = repair(date.getMonth() + 1); //月
				var day = repair(date.getDate()); //日
				var curTime = year + "-" + month + "-" + day
			
				function repair(i) {
					if (i >= 0 && i <= 9) {
						return "0" + i;
					} else {
						return i;
					}
				}
				return curTime
			},
			history(){
				let kehu= {
					id:this.dataAll.customers_id,
					name:this.dataAll.customer_name
				}
				uni.navigateTo({
					url:'/pages/workbench/xiaoshou/yewuybfjl?msg=' + encodeURIComponent(JSON.stringify(kehu))
				})
			},
		}
	}

</script>

<style lang="scss" scoped>
	.time {
		width: 35rpx;
		height: 35rpx;
		background-image: url("@/static/image/system/time.png");
		background-size: 100% 100%;
	}

	.selectdui {
		width: 49rpx;
		height: 49rpx;
	}

	.signed {
		font-size: 28rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #000000;
	}

	.time-text {
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #000000;
		margin-top: 14rpx;
	}

	.righttext {
		margin-left: 25rpx;
	}
	.rtimg{
		width: 100rpx;
		height: 100rpx;
		box-shadow: 0px 4rpx 12rpx 2rpx rgba(0,0,0,0.0200);
		border-radius: 16rpx 16rpx 16rpx 16rpx;
	}
	.images{
		width: 150rpx;
		height: 150rpx;
		box-shadow: 0rpx 4rpx 12rpx 2rpx rgba(0,0,0,0.0200);
		border-radius: 16rpx 16rpx 16rpx 16rpx;
	}
	
	.textcontent{
		font-size: 28rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #666666;
	}
	.bottomboxs{
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		box-sizing: border-box;
	}
	.bottombox {
		width: 25%;
	}
	.paddingbom{
		padding-bottom: 160rpx;
	}
</style>
